/* TCSS 590A - Cybernetics and Systems
 * Group Project - Modeling
 * By Barry Jones, Naren Meadem, Michael Pitts, Yuan Tao
 * Fall 2012, University of Washington, Tacoma
 */
package model.delayed.tactical;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import model.delayed.Event;


/**
 * Provides basic, default functionality for negotiation.  Every Event will be 
 * recommended as a negotiation candidate.
 * @author Michael Pitts
 * @version Nov 29, 2012
 */
public class DefaultNeg implements ShouldNegotiate
{
	/** The sign of Events to negotiate on.*/
	private final double my_sign;

	/**
	 * Creates a ShouldNegotiate object that will only negotiate Events with the 
	 * given sign.
	 * @param the_sign is the sign of Event values that will be negotiable.
	 */
	public DefaultNeg(final double the_sign)
	{
		my_sign = Math.signum(the_sign);
	}
	
	@Override public Map<Event, Long> negotiate(final long the_time,
			final Collection<Event> the_events)
	{
		final Map<Event, Long> map = new HashMap<Event, Long>();
		for (Event e : the_events) 
			if(Math.signum(e.value) == my_sign) map.put(e, Math.round(my_sign * 0.5 * e.value));
		return map;
	}
}
